/*
 * bsp_rmu.h
 *
 *  Created on: 2023年7月22日
 *      Author: HXF
 */

#ifndef BSP_RMU_H_
#define BSP_RMU_H_

#include "stdint.h"

typedef enum{
  DS_RSTCAUSE_POR = 0,      //power On Reset
  DS_RSTCAUSE_PIN,          //Pin Reset
  DS_RSTCAUSE_EM4,          //EM4 Wakeup Reset
  DS_RSTCAUSE_WDOG0,        //Watchdog 0 Reset
  DS_RSTCAUSE_WDOG1,        //Watchdog 1 Reset
  DS_RSTCAUSE_LOCKUP,       //M33 Core Lockup Reset
  DS_RSTCAUSE_SYSREQ,       //M33 Core Sys Reset
  DS_RSTCAUSE_DVDDBOD,      //HVBOD Reset
  DS_RSTCAUSE_DVDDLEBOD,    //LEBOD Reset
  DS_RSTCAUSE_DECBOD,       //LVBOD Reset
  DS_RSTCAUSE_AVDDBOD,      //LEBOD1 Reset
  DS_RSTCAUSE_IOVDD0BOD,    //LEBOD2 Reset
  DS_RSTCAUSE_SETAMPER,     //SE Tamper event Reset
  DS_RSTCAUSE_VREGIN,       //DCDC VREGIN comparator
  DS_RSTCAUSE_OTHER,        //unknown
}DS_RSTCAUSE_E;

/**
 * @brief ds_rmu_init 复位原因模组初始化
 * @param none
 * @return 0 初始化成功；1 已经初始化成功，不需要重复初始化； 2 初始化失败
 */
uint32_t ds_rmu_init(void);

/**
 * @brief ds_get_reset_cause 查询复位原因
 * @param none
 * @return DS_RSTCAUSE_E类型的复位原因
 *          比如上电引起，返回 DS_RSTCAUSE_POR
 *          Watchdog0引起，返回 DS_RSTCAUSE_WDOG0
 */
DS_RSTCAUSE_E ds_get_reset_cause(void);

void resetToString(uint32_t rst_cause, char *reason);

DS_RSTCAUSE_E getRestReason(void);
#endif /* BSP_RMU_H_ */
